#include <stdio.h>



int countperbit(int num,int factor)
{
	int count =0 ;
	count = (num/10+(num%10?1:0))*factor;
	printf("%d\n" ,factor);
	printf("%d\n",count );
	printf ("\n");
	return (num/10+(num%10?1:0))*factor;

}

int count (int num)
{
	int factor = 1;
	int place = 1 ;
	int count = 0 ;
	while(num/place)
	{
		count += countperbit(num/place,factor);
		factor *= 10;
		place  *= 10;
	}
	return count;
}

int main(int argc, int* argv[])
{
	int num = 0;
	for (int i =0;i<argc;i++)
	{
		num =argv[i+1][0];
		printf ("num = %d\n",num);
		printf ( "count of 1 in num is %d\n",count(num));
		return 0;
	}
	
}